#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''eof
name:申请人与企业负责人不一致
code:Applicant_Not_LegalPerson
tableName:
columnName:
groups:准入>烟商
dependencies:EG
type:常用指标
dataSourceType:在线指标
description:
eof'''

'''
ratingRequest:取申请人
EG basic 中： 取企业法定代表人： frname
二者一致返回 1  
法人或申请人为null或者空时，返回缺失值
'''
import sys
import pandas as pd
import datetime

reload(sys)
sys.setdefaultencoding('utf-8')

def Applicant_Not_LegalPerson():
    null_type_list = ['', None, 'null', 'Null', 'NULL', '/', ' ']

    try:
        jbxx = EG['srcData'][0]['EG']['results'][0]['jbxx']
    except:
        return u'缺失值'
    try:
        if jbxx.has_key('frname') and jbxx['frname'] not in null_type_list \
            and ratingRequest.has_key('legalPerson') \
            and ratingRequest['legalPerson'] not in null_type_list:
            if jbxx['frname'] == ratingRequest['legalPerson']:
                return 1
            else:
                return 0
        else:
            return u'缺失值'
    except:
        return u'缺失值'

result = Applicant_Not_LegalPerson()